package com.ksyun.campus.client;

import com.ksyun.campus.client.domain.ClusterInfo;
import com.ksyun.campus.client.domain.StatInfo;
import com.ksyun.campus.client.service.EFileService;
import com.ksyun.campus.client.service.impl.EFileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class EFileSystem extends FileSystem{

    private String fileName="default";
    public EFileSystem() {
    }

    public EFileSystem(String fileName) {
        if (!fileName.startsWith("/")) {
            fileName = "/" + fileName;
        }
        this.fileName = fileName;
    }

    EFileService eFileService=new EFileServiceImpl();

    //创建文件写入流用于读操作
    public FSInputStream open(String path){
        return eFileService.open(fileName,path);
    }

    //创建文件输出流用于写操作
    public FSOutputStream create(String path){
        return eFileService.create(fileName,path);
    }

    public boolean mkdir(String path){
        return eFileService.mkdir(fileName,path);
    }

    public boolean delete(String path){
        return eFileService.delete(fileName,path);
    }

    public StatInfo getFileStats(String path){
        return eFileService.getFileStats(fileName,path);
    }

    public List<StatInfo> listFileStats(String path){
        //获取文件夹中所有文件的信息
        return eFileService.listFileStats(fileName,path);
    }

    public ClusterInfo getClusterInfo(){
        return eFileService.getClusterInfo();
    }

}
